/**
 * 
 */
package com.xinthe.payment.service;

import javax.jws.WebMethod;
import javax.jws.WebService;

import com.xinthe.payment.utils.ValidationUtil;

/**
 * @author Sudarshan
 *
 */
@WebService(endpointInterface = "com.xinthe.payment.service.PaymentValidation")
public class PaymentValidationImpl implements PaymentValidation {

	@WebMethod
	public String validatePaymentDetails(String cardNumber, String cardType,
			String amount) {

		String result = "Authorized";

		if (!ValidationUtil.isValidCard(cardNumber)) {
			result = "Invalid Card";
			return result;
		}

		if (!ValidationUtil.isValidCardType(cardType)) {
			result = "Invalid Card Type";
			return result;
		}

		if (!ValidationUtil.isValidAmount(amount)) {
			result = "Invalid Amount";
			return result;
		}

		return result;
	}
}
